package com.ihr360.payroll;

import com.ihr360.admin.client.controller.health.AdminHealthCheck;
import feign.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;


@SpringCloudApplication
@ComponentScan(basePackages = "com.ihr360", excludeFilters =
        {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = AdminHealthCheck.class)})
@EnableScheduling
@EnableFeignClients(basePackages = {"com.ihr360.sharedservice.api","com.ihr360.shared.exceptionmail.service"})
@EnableAsync
@EnableAspectJAutoProxy(exposeProxy = true)
@PropertySource(value = "classpath:git.properties", ignoreResourceNotFound = true)
@EnableCaching
public class Ihr360PayrollApplication {

    public static void main(String[] args) {
        SpringApplication.run(Ihr360PayrollApplication.class, args);
    }


    /**
     * 修改feign的默认log级别，默认为NONE， 什么都不输出
     *
     * @return
     */
    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

//	@Bean
//	public OpenSessionInViewFilter openSessionInViewFilter() {
//		OpenSessionInViewFilter openSessionInViewFilter = new OpenSessionInViewFilter();
//		return openSessionInViewFilter;
//	}
//	@Bean
//	@Autowired
//	public LocalSessionFactoryBean sessionFactory(DataSource dataSource) {
//		LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
//
//		sessionFactory.setDataSource(dataSource); //设置数据源
//		sessionFactory.setPackagesToScan("com.ihr360"); //设置实体类扫描位置
//
//		return sessionFactory;
//	}
//	/**
//	 * 配置事务管理器
//	 *
//	 * @param sessionFactory
//	 * @return
//	 */
//	@Bean
//	@Autowired
//	public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
//		return new HibernateTransactionManager(sessionFactory);
//	}
}
